package com.bawei.library_base.mvvm;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import org.jetbrains.annotations.NotNull;

/**
 * @author : zhiyu
 * @date :
 * @content :
 */
public abstract class BaseMVVMFragment<VM extends BaseViewModel,DB extends ViewDataBinding>
extends BaseFragment{

    protected View view;
    protected VM viewModel;
    protected DB DataBinding;


    @Nullable
    @org.jetbrains.annotations.Nullable
    @Override
    public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        DataBinding=DataBindingUtil.inflate(inflater,bindLayout(),container,false);
        return DataBinding.getRoot();
    }

    @Override
    protected void initEnv() {
        viewModel=createViewModel();
    }
    protected abstract VM createViewModel();
}
